/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pe.com.transportes.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import pe.com.transportes.modelo.Asistente;

/**
 *
 * @author PFR
 */
public class AsistenteDAO {


      public void insertarasistente(Connection con,Asistente c) throws SQLException{

    String sql ="insert into asistente values (?,?,?,?,?,?,?)";
    PreparedStatement ps = con.prepareStatement(sql);


    System.out.println("codigo dao "+c.getCod_asistente());

    ps.setInt(1,c.getCod_asistente());
             ps.setString(2,c.getNom_asistente());
        ps.setString(3,c.getApe_asistente());
        ps.setInt(4,c.getTelefono());
        ps.setString(5,c.getFnacimiento());
        ps.setDouble(6, c.getSueldo());
  
   ps.setString(7, c.getTurno());
    ps.executeUpdate();
    }

    public ArrayList<Asistente> Listaasistentes(Connection con) throws SQLException{

          ArrayList<Asistente> lista = new ArrayList<Asistente>();
         
  String sql = "select * from asistente";

        PreparedStatement ps = con.prepareStatement(sql);

          ResultSet rs = ps.executeQuery();
      while(rs.next()){
 Asistente bean = new Asistente();
        bean.setCod_asistente(rs.getInt(1)) ;
        bean.setNom_asistente(rs.getString(2));
        bean.setApe_asistente(rs.getString(3));
        bean.setTelefono(rs.getInt(4));
        bean.setFnacimiento(rs.getString(5));
        bean.setSueldo(rs.getDouble(6));
         bean.setTurno(rs.getString(7));

         lista.add(bean);
        }
        return lista;


}
















}
